package org.frog.sgs.client.process.all;

import org.apache.mina.core.session.IoSession;
import org.frog.sgs.card.basic.Basic;
import org.frog.sgs.card.equipment.Equipment;
import org.frog.sgs.card.scheme.type.JudgeType;
import org.frog.sgs.client.game.ClientInstance;
import org.frog.sgs.client.process.ClientProcessor;
import org.frog.sgs.data.GameDataManager;
import org.frog.sgs.io.SgsMsg;

/**
 * @author duanxiangqi
 * @date 2012-10-26
 */
public class ClientProcessorSyncCharacterInfo implements ClientProcessor {

	public void process(IoSession session, SgsMsg msg, ClientInstance instance) throws Exception {
		int strength = msg.readInt();
		instance.getStrength().setStrength(strength);
		int size1 = msg.readInt();
		instance.getCardsInHand().clear();
		for (int i = 0; i < size1; i++) {
			int cardId = msg.readInt();
			Basic card = GameDataManager.instance.getBasicCopy(cardId);
			instance.getCardsInHand().put(cardId, card);
		}
		int size2 = msg.readInt();
		instance.getEquipments().clear();
		for (int i = 0; i < size2; i++) {
			int position = msg.readInt();
			int cardId = msg.readInt();
			Equipment card = (Equipment) GameDataManager.instance.getBasicCopy(cardId);
			instance.getEquipments().put(position, card);
		}
		int size3 = msg.readInt();
		instance.getJudgeSchemes().clear();
		for (int i = 0; i < size3; i++) {
			int judgeId = msg.readInt();
			int cardId = msg.readInt();
			Basic card = GameDataManager.instance.getBasicCopy(cardId);
			JudgeType judgeType = JudgeType.get(judgeId);
			instance.getJudgeSchemes().put(judgeType, card);
		}
		instance.showSelf();
	}
}
